A relational database management system contains relational tables each made up of rows and columns. To extract data from, or to update, a relational table, queries according to a standard database query language (such as the Structured Query Language or SQL) are used.
Examples of SQL statements include INSERT, SELECT, UPDATE, and DELETE. The SELECT statement is used to retrieve information from the database and to organize information for presentation to a user or an application program. The INSERT statement is used to insert a row (or multiple rows) into a table. The DELETE statement is used to delete a row (or multiple rows) from a table. The UPDATE statement is used to modify or change the content of the table. When a SQL query is received by a database system, a parser interprets the query statement, checks the statement for proper SQL syntax, and evaluates it semantically.
Traditionally, a relational database management system stores data according to relatively simple data types, such as the number data type for representing numeric values, character string data type for representing a sequence of characters, and so forth. To enhance the ability to store different types of data, user-defined data types (UDTs) have been introduced. For example, UDTs are provided by SQL:1999, which is a more recent version of SQL. SQL:1999 defines both predefined data types and UDTs. Predefined data types are the simple data types referred to above that are defined by the database query language itself. On the other hand, UDTs are set by an application, a database management system, or by another standard (other than the database query language standard).
A UDT is also associated with various user-defined methods, which are software routines or modules that can be created by database users for performing various operations on stored data according to the UDT. In addition to user-defined methods that can be created by a database user, UDTs are usually associated with an observer method and a mutator method. The observer method enables the database system to retrieve a UDT attribute value. The mutator method enables the database system to change the value of a UDT attribute.
A UDT method is usually invoked by an SQL query. It is possible to “nest” UDT methods in a query. Nested UDT methods refer to methods that are invoked by another UDT method. In parsing queries that contain nested methods, a conventional parser has to resolve the nesting of methods. This typically entails the re-writing of the query to expressly call out methods that are invoked by other methods. In many cases, the re-writing of a query containing nested UDTs results in an inefficient query that contains redundant instantiations of one or more UDTs and redundant invocations of one or more UDT methods. Redundant instantiations and invocations result in increased processing time for the database query, which causes database system performance to suffer.